Skip to content

Default Android vcpkg builds to Java HTTP#1510

Open
bmehta001 wants to merge 4 commits into
microsoft:mainfrom
bmehta001:bhamehta/android-http-client-option
Open

Default Android vcpkg builds to Java HTTP#1510
bmehta001 wants to merge 4 commits into
microsoft:mainfrom
bmehta001:bhamehta/android-http-client-option

Conversation

@bmehta001

@bmehta001 bmehta001 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Problem

Android vcpkg builds should not use MATSDK_USE_VCPKG_DEPS to decide the HTTP transport. Dependency sourcing and transport selection are separate concerns.

Android apps already package Java/JNI integration for platform context, device/system/network/power state, cache path, and lifecycle. The Android Java HTTP bridge is therefore the right default transport. Native curl is still useful as an explicit escape hatch for unusual native-only Android consumers.

Changes

  • Add MATSDK_ANDROID_HTTP_CLIENT=AUTO|JAVA|CURL.
    • On Android, AUTO now resolves to JAVA.
    • CURL remains available as an explicit override.
  • Make Android vcpkg builds default to HttpClient_Android instead of curl.
  • Add explicit Android curl override features:
    • android-curl-openssl
    • android-curl-mbedtls
  • Install the Android Java HTTP bridge sources for vcpkg consumers:
    • HttpClient.java
    • HttpClientRequest.java
  • Export Android HTTP transport metadata from the CMake package config.
  • Update vcpkg documentation for the Java default, Java bridge packaging, AndroidX annotation dependency, and curl escape hatch.
  • Fix Android PAL initializer-order warnings that current NDK Clang reports under -Werror.

Validation

  • Android vcpkg default Java path:
    • vcpkg install cpp-client-telemetry[core,system-sqlite] --triplet arm64-android --overlay-ports=tools/ports
    • Verified the install did not include curl and MATSDK_ANDROID_HTTP_CLIENT=AUTO configured successfully.
  • Android explicit curl override:
    • vcpkg install cpp-client-telemetry[core,android-curl-openssl,system-sqlite] --triplet arm64-android --overlay-ports=tools/ports
    • Verified the configure cache used MATSDK_ANDROID_HTTP_CLIENT=CURL.
  • vcpkg format-manifest tools/ports/cpp-client-telemetry/vcpkg.json
  • Final material code review completed.

Note

The in-repo overlay port now builds the checkout source by default. When publishing this feature to the registry, bump the port REF/SHA512 to a release that contains MATSDK_ANDROID_HTTP_CLIENT.

Decouple Android HTTP transport choice from MATSDK_USE_VCPKG_DEPS so consumers can use vcpkg-provided native dependencies while still packaging the Java/JNI transport.

Files changed:

- CMakeLists.txt, lib/CMakeLists.txt, cmake/MSTelemetryConfig.cmake.in: add MATSDK_ANDROID_HTTP_CLIENT and export Android Java source metadata.

- tools/ports/cpp-client-telemetry/*, docs/building-with-vcpkg.md: add android-java-http feature, source guard, and consumer documentation.

- lib/pal/posix/*_Android.cpp: align initializer order for current NDK Clang builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41
@bmehta001
bmehta001 requested a review from a team as a code owner July 22, 2026 08:04
Make Android AUTO select the Java/JNI HTTP transport regardless of dependency sourcing, and require explicit android-curl-* features for native curl.

Files changed:

- CMakeLists.txt: resolve Android AUTO to JAVA.

- tools/ports/cpp-client-telemetry/portfile.cmake: use the in-repo checkout for overlay builds and add explicit Android curl feature handling.

- tools/ports/cpp-client-telemetry/vcpkg.json: move Android curl to explicit android-curl-openssl/android-curl-mbedtls features.

- docs/building-with-vcpkg.md: document Java default and curl escape hatch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41
@bmehta001 bmehta001 self-assigned this Jul 22, 2026
@bmehta001 bmehta001 changed the title Add Android HTTP transport selection for vcpkg Default Android vcpkg builds to Java HTTP Jul 22, 2026
@bmehta001
bmehta001 requested a review from Copilot July 22, 2026 22:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the Android vcpkg build defaults to use the Java/JNI HTTP transport (instead of implicitly selecting curl based on vcpkg dependency mode), while keeping native curl available as an explicit Android-only escape hatch.

Changes:

  • Introduces MATSDK_ANDROID_HTTP_CLIENT=AUTO|JAVA|CURL and makes AUTO resolve to JAVA on Android, wiring this through both CMake and the vcpkg port.
  • Splits Android curl selection into explicit vcpkg features (android-curl-openssl, android-curl-mbedtls) and installs the Java bridge sources for vcpkg consumers when Java transport is selected.
  • Updates vcpkg documentation and fixes Android PAL constructor initializer ordering to address new -Werror warnings.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/ports/cpp-client-telemetry/vcpkg.json Adds Android-specific curl override features; refines Linux curl feature platform scoping; keeps defaults oriented to Linux.
tools/ports/cpp-client-telemetry/portfile.cmake Selects MATSDK_ANDROID_HTTP_CLIENT for Android vcpkg builds and validates feature combinations (Linux vs Android curl features).
lib/pal/posix/SystemInformationImpl_Android.cpp Reorders initializer list to match member declaration order (avoids -Wreorder warnings).
lib/pal/posix/NetworkInformationImpl_Android.cpp Reorders initializer list for -Wreorder (and touches Android network cost initialization).
lib/pal/posix/DeviceInformationImpl_Android.cpp Reorders initializer list for -Wreorder.
lib/CMakeLists.txt Switches Android source selection between HttpClient_Android and curl based on the resolved Android transport; installs Java bridge sources for vcpkg Java transport.
docs/building-with-vcpkg.md Documents Android Java default, curl escape hatch, installed Java bridge source location, and AndroidX annotation dependency.
CMakeLists.txt Adds the MATSDK_ANDROID_HTTP_CLIENT option, resolves AUTO to JAVA on Android, and updates curl-need logic to depend on the resolved Android transport.
cmake/MSTelemetryConfig.cmake.in Exports Android HTTP transport metadata and Java source directory from the installed CMake package config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 44 to 47
NetworkInformationImpl::NetworkInformationImpl(IRuntimeConfig& configuration) :
m_info_helper(),
m_cost(NetworkCost_Unknown),
m_info_helper(),
m_isNetDetectEnabled(configuration[CFG_BOOL_ENABLE_NET_DETECT]){};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4e6db99 and completed in 5982520. m_registeredCount is now initialized to 0 and the related m_type getter state is initialized to NetworkType_Unknown in lib/pal/posix/NetworkInformationImpl_Android.cpp:44-49. No further change needed for this thread.

Comment on lines 54 to 57
DeviceInformationImpl::DeviceInformationImpl(IRuntimeConfig& configuration) :
m_info_helper(),
m_powerSource(PowerSource_Battery)
m_powerSource(PowerSource_Battery),
m_info_helper()
{}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4e6db99 and completed in 5982520. m_registeredCount is now initialized to 0, and m_os_architecture is initialized to OsArchitectureType_Unknown, in lib/pal/posix/DeviceInformationImpl_Android.cpp:54-59. No further change needed for this thread.

Comment on lines +30 to +33
set(MSTelemetry_ANDROID_HTTP_CLIENT "@MATSDK_ANDROID_HTTP_CLIENT_RESOLVED@")
set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR
"${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4e6db99 and refined in 5982520. The comment now says curl is re-found for Linux, explicit Android curl builds, and macOS without Apple HTTP; it explicitly excludes default Android Java/JNI HTTP in cmake/MSTelemetryConfig.cmake.in:16-19. No further change needed for this thread.

NetworkInformationImpl_Android.cpp: initialize m_registeredCount so callback registration bookkeeping does not read an indeterminate value. Verified m_registeredCount is incremented/decremented in lib/pal/NetworkInformationImpl.hpp.

DeviceInformationImpl_Android.cpp: initialize m_registeredCount for the same callback bookkeeping path. Verified m_registeredCount is incremented/decremented in lib/pal/DeviceInformationImpl.hpp.

MSTelemetryConfig.cmake.in: update the curl dependency comment to reflect Linux, explicit Android curl builds, and macOS-without-Apple-HTTP only.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

lib/pal/posix/NetworkInformationImpl_Android.cpp:47

  • NetworkInformationImpl leaves m_registeredCount (and m_type) uninitialized. Because the base class inline Register/Unregister methods increment/decrement m_registeredCount and GetNetworkType() returns m_type, this is undefined behavior on Android builds.
    NetworkInformationImpl::NetworkInformationImpl(IRuntimeConfig& configuration) :
        m_cost(NetworkCost_Unknown),
        m_info_helper(),
        m_registeredCount(0),

lib/pal/posix/DeviceInformationImpl_Android.cpp:57

  • DeviceInformationImpl leaves m_os_architecture and m_registeredCount uninitialized. GetOsArchitectureType() returns m_os_architecture directly and the inline Register/Unregister callback methods update m_registeredCount, so this is undefined behavior on Android.
    DeviceInformationImpl::DeviceInformationImpl(IRuntimeConfig& configuration) :
        m_powerSource(PowerSource_Battery),
        m_info_helper(),
        m_registeredCount(0)

Comment on lines +13 to +15
elseif(EXISTS "${CURRENT_PORT_DIR}/../../../CMakeLists.txt")
get_filename_component(SOURCE_PATH "${CURRENT_PORT_DIR}/../../.." ABSOLUTE)
message(STATUS "cpp-client-telemetry: building in-repo overlay source ${SOURCE_PATH}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5982520. The in-repo overlay detection now requires SDK-specific paths (CMakeLists.txt, lib/CMakeLists.txt, and tools/ports/cpp-client-telemetry/portfile.cmake) before treating ../../../ as the SDK checkout; otherwise it falls back to the pinned release path. See tools/ports/cpp-client-telemetry/portfile.cmake:17-28. No further change needed for this thread.

Comment on lines +30 to +33
set(MSTelemetry_ANDROID_HTTP_CLIENT "@MATSDK_ANDROID_HTTP_CLIENT_RESOLVED@")
set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR
"${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5982520. MSTelemetry_ANDROID_JAVA_SOURCE_DIR is now populated only when MSTelemetry_ANDROID_HTTP_CLIENT is JAVA; otherwise it is set to an empty string. See cmake/MSTelemetryConfig.cmake.in:31-37. No further change needed for this thread.

portfile.cmake: make in-repo overlay source detection require SDK-specific paths so registry/vcpkg checkouts cannot be mistaken for cpp_client_telemetry.

MSTelemetryConfig.cmake.in: set MSTelemetry_ANDROID_JAVA_SOURCE_DIR only for Java-transport packages; set it empty otherwise.

Android PAL: initialize m_type and m_os_architecture alongside the callback counters so inline getters never read indeterminate values.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment on lines 83 to +86
message(FATAL_ERROR
"curl-openssl (default) and curl-mbedtls are mutually exclusive but both were "
"selected. To use mbedTLS, drop the defaults with the [core,...] form and "
"re-select a SQLite backend (the [core,...] form also drops the default "
"system-sqlite feature), e.g. "
"cpp-client-telemetry[core,curl-mbedtls,system-sqlite] "
"(or minimal-sqlite in place of system-sqlite).")
elseif(_matsdk_http_feature_count EQUAL 0)
"The curl HTTP backend features are mutually exclusive but multiple were "
"selected. On Linux, use exactly one of curl-openssl/curl-mbedtls. On "
"Android, use exactly one of android-curl-openssl/android-curl-mbedtls.")
Comment on lines +31 to +37
set(MSTelemetry_ANDROID_HTTP_CLIENT "@MATSDK_ANDROID_HTTP_CLIENT_RESOLVED@")
if(MSTelemetry_ANDROID_HTTP_CLIENT STREQUAL "JAVA")
set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR
"${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java")
else()
set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR "")
endif()

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants